package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.nio.charset.StandardCharsets;
import java.util.List;

/**
 * @author zhaokai
 * @module s
 * @project springboot-alarm-api
 * @package com.example.demo.config
 * @email 1107313968@qq.com
 * @date 2025-07-01 - 14:17
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
      @Override
      public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
            // 设置JSON解析器的编码为UTF-8
            MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
            converter.setDefaultCharset(StandardCharsets.UTF_8);
            converters.add(0, converter);
      }
}